<?php

/**
 * 新闻资讯页面
 * author:wang
 */
define("PHP_IN",true);
require "include/init.php";
require ROOT_PATH."smarty_connection.php";

$page = isset($_GET['page']) ? $_GET['page'] : 1;
$pagesize = 3;
$pagestart = ($page-1) * $pagesize;

$where = "isdisplay = 1";
$sql = "SELECT count(*) AS num FROM news WHERE $where";
$result = $db->query($sql);
$count = 0;
$row = $db->fetch_one($result);
$count = $row['num'] ;

$pagecount = ceil($count/$pagesize);
$page_links = page_links($pagecount,$page,"news.php?$page");

$sql = "SELECT * FROM news WHERE $where ORDER BY newsid DESC LIMIT $pagestart,$pagesize";  //新闻资讯
$result = $db->query($sql);
$news = $db->fetch_all($result);

$smarty->assign("news",$news);
$smarty->assign("page",$page);
$smarty->assign("page_links",$page_links);

$smarty->display("news.tpl");
$db->close();

?>
